#include <ESP8266WiFi.h>

unsigned long previousMillis;
int ledState;

int LEDportBLUE1 = 16;
int LEDport1 = 14;
int controlLED = 5;

void setup()
{
  pinMode(LEDportBLUE1, OUTPUT);
  pinMode(LEDport1, OUTPUT);
  pinMode(controlLED, INPUT_PULLUP);
  digitalWrite(LEDportBLUE1, LOW);
}

void ledBlink(int ledPin, uint32_t period)
{
  unsigned long currentMillis = millis();       /* 记录当前时间 */
  if (currentMillis - previousMillis >= period) /* 检查 "period"  ms是否通过 */
  {
    ledState = digitalRead(ledPin);
    previousMillis = currentMillis; /* 保存上次闪烁LED时 */
    if (ledState == LOW)            /* 如果LED关闭，则打开，反之亦然 */
    {
      ledState = HIGH;
    }
    else
    {
      ledState = LOW;
    }
    digitalWrite(ledPin, ledState); /* LED为ledState状态 */
  }
}

void loop()
{
  ledBlink(LEDportBLUE1, 1000);
  // 检查引脚controlLED的输入情况
  // 将controlLED号引脚输入赋给变量val
  // 开关闭合后，引脚2将获得
  // 低电平信号(val = LOW)
  int val = digitalRead(controlLED);
  // 开关闭合后，引脚controlLED将获得
  // 低电平信号(val = LOW)
  // 在 val = LOW时，点亮
  // 引脚LEDport1旁的LED。
  // 否则保持LED熄灭状态
  if (val == HIGH)
  {
    digitalWrite(LEDport1, LOW);
  }
  else
  {
    digitalWrite(LEDport1, HIGH);
  }
}
